#include "bflb_mtimer.h"
#include "bflb_i2c.h"
#include "board.h"
#include "INA226.h"
#include "bflb_gpio.h"

struct bflb_device_s *i2c0;

void setup() {
  struct bflb_device_s* iicgpio;
  board_init();

  iicgpio = bflb_device_get_by_name("gpio");
  /* I2C0_SCL */
  bflb_gpio_init(iicgpio, GPIO_PIN_0, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
  /* I2C0_SDA */
  bflb_gpio_init(iicgpio, GPIO_PIN_1, GPIO_FUNC_I2C0 | GPIO_ALTERNATE | GPIO_PULLUP | GPIO_SMT_EN | GPIO_DRV_1);
  i2c0 = bflb_device_get_by_name("i2c0");

  bflb_i2c_init(i2c0, 400000);
  bflb_mtimer_delay_ms(1000);
  INA226_Init();

}

void loop() {
  bflb_mtimer_delay_ms(1000);
  INA226_TEST();
}
